{{- define "csi_cloud_config" }}
  {{- $providerClusterConfiguration := .Values.cloudProviderZvirt.internal.providerClusterConfiguration | required "internal.providerClusterConfiguration is required" -}}
ovirt_url: {{ $providerClusterConfiguration.provider.server }}
ovirt_username: {{ $providerClusterConfiguration.provider.username }}
ovirt_password: {{ $providerClusterConfiguration.provider.password }}
ovirt_insecure: {{ $providerClusterConfiguration.provider.insecure | default false }}
  {{- if not (eq $providerClusterConfiguration.provider.caBundle "") }}
ovirt_cafile: "/etc/cloud/ca/zvirt_ca.pem"
  {{- end }}
clusterid: {{ .Values.global.discovery.clusterUUID }}
{{- end }}
---
apiVersion: v1
kind: Secret
metadata:
  name: csi-controller-manager
  namespace: d8-cloud-provider-zvirt
  {{- include "helm_lib_module_labels" (list . (dict "app" "csi-controller")) | nindent 2 }}
type: Opaque
data:
  cloud-config: {{ include "csi_cloud_config" . | b64enc | quote }}
{{- if not (eq .Values.cloudProviderZvirt.internal.providerClusterConfiguration.provider.caBundle "") }}
---
apiVersion: v1
kind: Secret
metadata:
  name: csi-controller-manager-ca
  namespace: d8-cloud-provider-zvirt
  {{- include "helm_lib_module_labels" (list . (dict "app" "csi-controller")) | nindent 2 }}
type: Opaque
data:
  zvirt_ca.pem: {{ .Values.cloudProviderZvirt.internal.providerClusterConfiguration.provider.caBundle | quote }}
{{- end }}
